package com.student.data.action;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

import com.student.data.dao.ForumDao;

//作者QQ 13 05 63 79 39
public class ForumAction extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private ServletFileUpload upload;
	private final long MAXSize = 4194304 * 2L;// 4*2MB
	private String filedir = null;
	private ForumDao hobbyDao;

	public ForumAction() {
		super();
	}

	public void destroy() {
		super.destroy();
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String path = request.getContextPath();
		response.setContentType("text/html;charset=utf-8");
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();

		String action_flag = request.getParameter("action_flag");
		if (action_flag.equals("addMessage")) {
			addMessage(request, response);
		} else if (action_flag.equals("listMessage")) {
			listMessage(request, response);
		} else if (action_flag.equals("listPhoneMessage")) {
			listPhoneMessage(request, response);
		} else if (action_flag.equals("updateReview")) {
			updateReview(request, response);
		} else if (action_flag.equals("deleteMessage")) {
			deleteMessage(request, response);
		} else if (action_flag.equals("listMessageChoice")) {
			listMessageChoice(request, response);
		} else if (action_flag.equals("listSearchMessage")) {
			listSearchMessage(request, response);
		} else if (action_flag.equals("addAppoinment")) {
			addAppointment(request, response);
		} else if (action_flag.equals("listAppointmentMessage")) {
			listAppointmentMessage(request, response);
		} else if (action_flag.equals("listDoctorQueryAppointmentMessage")) {
			listDoctorQueryAppointmentMessage(request, response);
		} else if (action_flag.equals("addMRMessage")) {
			addMRMessage(request, response);
		} else if (action_flag.equals("queryMRMessage")) {
			queryMRMessage(request, response);
		} else if (action_flag.equals("addInterest")) {
			addInterest(request, response);
		} else if (action_flag.equals("listInterestMessage")) {
			listInterestMessage(request, response);
		} else if (action_flag.equals("listInterestUserMessage")) {
			listInterestUserMessage(request, response);
		} else if (action_flag.equals("deleteInterest")) {
			deleteInterest(request, response);
		} else if (action_flag.equals("deletePcInterest")) {
			deletePcInterest(request, response);
		} else if (action_flag.equals("addCollectMessage")) {
			addCollectMessage(request, response);
		} else if (action_flag.equals("deleteCollectMessage")) {
			//deleteCollectMessage(request, response);
		} else if (action_flag.equals("addType")) {
			addType(request, response);
		} else if (action_flag.equals("listTypeMessage")) {
			listTypeMessage(request, response);
		} else if (action_flag.equals("deleteType")) {
			deleteType(request, response);
		} else if (action_flag.equals("addScenery")) {
			addScenery(request, response);
		} else if (action_flag.equals("listSceneryMessage")) {
			listSceneryMessage(request, response);
		} else if (action_flag.equals("deleteScenery")) {
			deleteScenery(request, response);
		} else if (action_flag.equals("listSceneryPhoneMessage")) {
			listSceneryPhoneMessage(request, response);
		} else if (action_flag.equals("listPhonePlanMessage")) {
			listPhonePlanMessage(request, response);
		} else if (action_flag.equals("deletePlanMessage")) {
			deletePlanMessage(request, response);
		} else if (action_flag.equals("listTypePhoneMessage")) {
			listTypePhoneMessage(request, response);
		} else if (action_flag.equals("deletePlan")) {
			deletePlan(request, response);
		} else if (action_flag.equals("listPlanMessage")) {
			listPlanMessage(request, response);
		} else if (action_flag.equals("listPlanMessage")) {
			listPlanMessage(request, response);
		} else if (action_flag.equals("listTiziMessage")) {
			listTiziMessage(request, response);
		} else if (action_flag.equals("addLineMessage")) {
			addLineMessage(request, response);
		} else if (action_flag.equals("listLineMessage")) {
			listLineMessage(request, response);
		} else if (action_flag.equals("listLinePhoneMessage")) {
			listLinePhoneMessage(request, response);
		} else if (action_flag.equals("addApply")) {
			addApply(request, response);
		} else if (action_flag.equals("listPhonePlanUserMessage")) {
			listPhonePlanUserMessage(request, response);
		} else if (action_flag.equals("listPhoneUserApplyMessage")) {
			listPhoneUserApplyMessage(request, response);
		} else if (action_flag.equals("addHotel")) {
			addHotel(request, response);
		} else if (action_flag.equals("listHotelMessage")) {
			listHotelMessage(request, response);
		} else if (action_flag.equals("listHotelPhoneMessage")) {
			listHotelPhoneMessage(request, response);
		} else if (action_flag.equals("addOrder")) {
			addOrder(request, response);
		} else if (action_flag.equals("listPhoneOrder")) {
			listPhoneOrder(request, response);
		}else if (action_flag.equals("listMessagePcOrder")) {
			listMessagePcOrder(request, response);
		}else if (action_flag.equals("addTicket")) {
			addTicket(request, response);
		}else if (action_flag.equals("ListMessageTicket")) {
			ListMessageTicket(request, response);
		}else if (action_flag.equals("listSearchTicketMessage")) {
			listSearchTicketMessage(request, response);
		}else if (action_flag.equals("addTicketOrder")) {
			addTicketOrder(request, response);
		}else if (action_flag.equals("listSearchTicketgOrderMessage")) {
			listSearchTicketgOrderMessage(request, response);
		}else if (action_flag.equals("listMessagePcTicketOrder")) {
			listMessagePcTicketOrder(request, response);
		}
	}

	public void init(ServletConfig config) throws ServletException {
		FileItemFactory factory = new DiskFileItemFactory();// Create a factory
		this.upload = new ServletFileUpload(factory);// Create a new file upload
		this.upload.setSizeMax(this.MAXSize);// Set overall request size
		filedir = config.getServletContext().getRealPath("upload");
		System.out.println("filedir=" + filedir);
		hobbyDao = new ForumDao();
	}
	
	
	private void listMessagePcTicketOrder(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		List<Map<String, Object>> list = hobbyDao.listMessagePcTicketOrder();
		request.setAttribute("listMessage", list);
		request.getRequestDispatcher("../orderTicketMessage.jsp").forward(request, response);

	}
	
	
	
	private void listSearchTicketgOrderMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String orderTicketUserId = request.getParameter("orderTicketUserId");

		List<Object> params = new ArrayList<Object>();
		params.add(orderTicketUserId);
		List<Map<String, Object>> list = hobbyDao.listSearchTicketgOrderMessage(params);
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", list);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}
	
	private void addTicketOrder(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();

		String orderTicketUserId = request.getParameter("orderTicketUserId");
		String orderTicketUserName = request.getParameter("orderTicketUserName");
		String orderTicketMessageId = request.getParameter("orderTicketMessageId");
		String orderTicketMessageName = request.getParameter("orderTicketMessageName");
		String orderTicketMoney = request.getParameter("orderTicketMoney");

		List<Object> params = new ArrayList<Object>();
		params.add(orderTicketUserId);
		params.add(orderTicketUserName);
		params.add(orderTicketMessageId);
		params.add(orderTicketMessageName);
		params.add(orderTicketMoney);
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");// 设置日期格式
		params.add(df.format(new Date()));

		boolean flagUpdate = hobbyDao.addTicketOrder(params);
		if (flagUpdate) {

			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "支付完成");
			jsonmsg.put("repCode", "666");
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
			System.out.println(jsonmsg);

		} else {
			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "添加失败");
			jsonmsg.put("repCode", "111");
			System.out.println(jsonmsg);
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
		}

	}


	private void listSearchTicketMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		String ticketStartCity = request.getParameter("ticketStartCity");
		String ticketEndCity = request.getParameter("ticketEndCity");
		List<Object> params = new ArrayList<Object>();
		params.add(ticketStartCity);
		params.add(ticketEndCity);
		List<Map<String, Object>> list = hobbyDao.listSearchTicketgMessage(params);
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", list);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}
	
	
	private void ListMessageTicket(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		List<Map<String, Object>> list = hobbyDao.listMessagePcticketmsg();
		request.setAttribute("listMessage", list);
		request.getRequestDispatcher("../ticketMessage.jsp").forward(request, response);

	}
	
	private void addTicket(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();

		String ticketStartCity = request.getParameter("ticketStartCity");
		String ticketEndCity = request.getParameter("ticketEndCity");
		String ticketMoney = request.getParameter("ticketMoney");

		List<Object> params = new ArrayList<Object>();
		params.add(ticketStartCity);
		params.add(ticketEndCity);
		params.add(ticketMoney);

		boolean flag = hobbyDao.addTicketmsgMessage(params);
		JSONObject jsonmsg = new JSONObject();
		if (flag) {
			ListMessageTicket(request, response);
		} else {
			jsonmsg.put("repMsg", "提交失败");
			jsonmsg.put("repCode", "111");
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
			System.out.println(jsonmsg);
		}
	}
	private void listMessagePcOrder(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		List<Map<String, Object>> list = hobbyDao.listMessagePcOrder();
		request.setAttribute("listMessage", list);
		request.getRequestDispatcher("../ordermsgMessage.jsp").forward(request, response);

	}
	
	
	

	private void listPhoneOrder(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String orderUserId = request.getParameter("orderUserId");

		List<Object> params = new ArrayList<Object>();
		params.add(orderUserId);
		List<Map<String, Object>> list = hobbyDao.listMessageOrder(params);
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", list);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void addOrder(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();

		String orderUserId = request.getParameter("orderUserId");
		String orderUserName = request.getParameter("orderUserName");
		String orderMessageId = request.getParameter("orderMessageId");
		String orderMessageName = request.getParameter("orderMessageName");

		List<Object> params = new ArrayList<Object>();
		params.add(orderUserId);
		params.add(orderUserName);
		params.add(orderMessageId);
		params.add(orderMessageName);
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");// 设置日期格式
		params.add(df.format(new Date()));

		boolean flagUpdate = hobbyDao.addOrder(params);
		if (flagUpdate) {

			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "支付完成");
			jsonmsg.put("repCode", "666");
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
			System.out.println(jsonmsg);

		} else {
			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "添加失败");
			jsonmsg.put("repCode", "111");
			System.out.println(jsonmsg);
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
		}

	}

	private void listHotelPhoneMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		List<Map<String, Object>> flagFood = hobbyDao.listhotelmsgTypeMessage();
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", flagFood);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void listHotelMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		List<Map<String, Object>> list = hobbyDao.listhotelmsgTypeMessage();
		request.setAttribute("listMessage", list);
		request.getRequestDispatcher("../hotelMessage.jsp").forward(request, response);

	}

	private void addHotel(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		final long MAX_SIZE = 2048 * 1024 * 1024;// 设置上传文件最大值为2G，可以改为更大
		// 表单含有文件要提交
		String path = request.getContextPath();
		DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
		// 构建一个文件上传类
		ServletFileUpload servletFileUpload = new ServletFileUpload(diskFileItemFactory);
		// servletFileUpload.setFileSizeMax(3 * 1024 * 1024);
		servletFileUpload.setSizeMax(MAX_SIZE);// 上传文件总大小
		List<FileItem> list = null;
		List<Object> params = new ArrayList<Object>();
		try {
			// 解析request的请求
			list = servletFileUpload.parseRequest(request);
			// 取出所有表单的值:判断非文本字段和文本字段
			for (FileItem fileItem : list) {
				if (fileItem.isFormField()) {
					if (fileItem.getFieldName().equals("hotelName")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));
					}

					if (fileItem.getFieldName().equals("hotelMoney")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));
					}

					if (fileItem.getFieldName().equals("hotelType")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));
					}
					if (fileItem.getFieldName().equals("hotelZuoBiao")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));
					}
					

					if (fileItem.getFieldName().equals("hotelMessage")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));

						SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");// 设置日期格式
						params.add(df.format(new Date()));
						System.out.println(df.format(new Date()));
					}

				} else {
					try {
						// String image = fileItem.getName();
						// System.out.println("image--->>" + image);
						// params.add(image);E:\2017-2018code\A1044VideoCourse\VideoCourseService
						// String upload_path = request.getRealPath("/upload");
						// System.out.println("--->>" + upload_path);
						// File real_path = new File(upload_path + "/" + image);
						// fileItem.write(real_path);E:\2018code\A832Tourism\TourismService
						String image = fileItem.getName();
						System.out.println("image111--->>" + image);
						params.add(image);
						String upload_path = request.getRealPath("/upload");
						System.out.println("--->>" + upload_path);
						
//						E:\2017-2017CDCode\Tourism\TourismService
						String imgPath = "E:\\2017-2017CDCode\\Tourism\\TourismService\\WebRoot\\upload";
						imgPath = request.getServletContext().getRealPath("/") + "\\upload";
						
						File real_path = new File(imgPath + "/" + image);
						fileItem.write(real_path);

						// 把数据插入到数据库中
					} catch (Exception e) {
						e.printStackTrace();
					}

					boolean flag = hobbyDao.addHotelMessage(params);
					System.out.println(flag);
					if (flag) {
						listHotelMessage(request, response);
					} else {
						System.out.println("flag:no");
					}

				}
			}
		} catch (FileUploadException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	private void listPhoneUserApplyMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String applyUserId = request.getParameter("applyUserId");
		List<Object> params = new ArrayList<Object>();
		params.add(applyUserId);
		List<Map<String, Object>> flagFood = hobbyDao.listPhonePlanApplyMessage(params);
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", flagFood);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void listPhonePlanUserMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String applyPlanId = request.getParameter("applyPlanId");
		List<Object> params = new ArrayList<Object>();
		params.add(applyPlanId);
		List<Map<String, Object>> flagFood = hobbyDao.listPhonePlanUserMessage(params);
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", flagFood);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void addApply(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		String applyUserId = request.getParameter("applyUserId");
		String applyUserName = request.getParameter("applyUserName");
		String applyPlanId = request.getParameter("applyPlanId");
		String applyPlanName = request.getParameter("applyPlanName");

		List<Object> paramsCheck = new ArrayList<Object>();
		paramsCheck.add(applyPlanId);
		paramsCheck.add(applyUserId);

		boolean flagCheck = hobbyDao.checkPlan(paramsCheck);

		if (!flagCheck) {
			List<Object> params = new ArrayList<Object>();
			params.add(applyUserId);
			params.add(applyUserName);
			params.add(applyPlanId);
			params.add(applyPlanName);
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");// 设置日期格式
			params.add(df.format(new Date()));

			boolean flag = hobbyDao.addApply(params);
			JSONObject jsonmsg = new JSONObject();
			if (flag) {
				jsonmsg.put("repMsg", "参与成功");
				jsonmsg.put("repCode", "666");
				response.getWriter().print(jsonmsg);// 将路径返回给客户端
				System.out.println(jsonmsg);
			} else {
				jsonmsg.put("repMsg", "提交失败");
				jsonmsg.put("repCode", "111");
				response.getWriter().print(jsonmsg);// 将路径返回给客户端
				System.out.println(jsonmsg);
			}
		} else {
			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "亲，不要重复参与哦！");
			jsonmsg.put("repCode", "1111");
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
			System.out.println(jsonmsg);
		}

	}

	private void listLinePhoneMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String userId = request.getParameter("userId");
		List<Map<String, Object>> flagFood = hobbyDao.listlinemsgMessage(userId);
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", flagFood);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void listLineMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		List<Map<String, Object>> list = hobbyDao.listlinemsgTypeMessage();
		request.setAttribute("listMessage", list);
		request.getRequestDispatcher("../lineMessage.jsp").forward(request, response);

	}

	private void addLineMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		final long MAX_SIZE = 2048 * 1024 * 1024;// 设置上传文件最大值为2G，可以改为更大
		// 表单含有文件要提交
		String path = request.getContextPath();
		DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
		// 构建一个文件上传类
		ServletFileUpload servletFileUpload = new ServletFileUpload(diskFileItemFactory);
		// servletFileUpload.setFileSizeMax(3 * 1024 * 1024);
		servletFileUpload.setSizeMax(MAX_SIZE);// 上传文件总大小
		List<FileItem> list = null;
		List<Object> params = new ArrayList<Object>();
		try {
			// 解析request的请求
			list = servletFileUpload.parseRequest(request);
			// 取出所有表单的值:判断非文本字段和文本字段
			for (FileItem fileItem : list) {
				if (fileItem.isFormField()) {
					if (fileItem.getFieldName().equals("lineName")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));
					}

					if (fileItem.getFieldName().equals("lineMoney")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));
					}

					if (fileItem.getFieldName().equals("lineDay")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));
					}

					if (fileItem.getFieldName().equals("lineMessage")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));

						SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");// 设置日期格式
						params.add(df.format(new Date()));
						System.out.println(df.format(new Date()));
					}

				} else {
					try {
						// String image = fileItem.getName();
						// System.out.println("image--->>" + image);
						// params.add(image);E:\2017-2018code\A1044VideoCourse\VideoCourseService
						// String upload_path = request.getRealPath("/upload");
						// System.out.println("--->>" + upload_path);
						// File real_path = new File(upload_path + "/" + image);
						// fileItem.write(real_path);
						String image = fileItem.getName();
						System.out.println("image111--->>" + image);
						params.add(image);
						String upload_path = request.getRealPath("/upload");
						System.out.println("--->>" + upload_path);
						String imgPath = "E:\\2017-2017CDCode\\Tourism\\TourismService\\WebRoot\\upload";
						imgPath = request.getServletContext().getRealPath("/") + "\\upload";
						File real_path = new File(imgPath + "/" + image);
						fileItem.write(real_path);

						// 把数据插入到数据库中
					} catch (Exception e) {
						e.printStackTrace();
					}

					boolean flag = hobbyDao.addLineMessage(params);
					System.out.println(flag);
					if (flag) {
						listLineMessage(request, response);
					} else {
						System.out.println("flag:no");
					}

				}
			}
		} catch (FileUploadException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	private void listTiziMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		List<Map<String, Object>> list = hobbyDao.listPhoneTieZiMessage();
		request.setAttribute("listMessage", list);
		request.getRequestDispatcher("../tieziMessage.jsp").forward(request, response);

	}

	private void listPlanMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		List<Map<String, Object>> list = hobbyDao.listPlanMessage();
		request.setAttribute("listMessage", list);
		request.getRequestDispatcher("../planMessage.jsp").forward(request, response);

	}

	private void deletePlan(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String planId = request.getParameter("planId");
		List<Object> params = new ArrayList<Object>();
		params.add(planId);
		boolean flag = hobbyDao.deletePlan(params);
		if (flag) {
			listTypeMessage(request, response);
		}

	}

	private void listTypePhoneMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		List<Map<String, Object>> list = hobbyDao.listTypeMessage();
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", list);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void deletePlanMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		String planId = request.getParameter("planId");
		List<Object> params = new ArrayList<Object>();
		params.add(planId);
		boolean flag = hobbyDao.deletePlan(params);
		if (flag) {
			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "删除成功");
			jsonmsg.put("repCode", "666");
			System.out.println(jsonmsg);
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
		} else {
			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "提交失败");
			jsonmsg.put("repCode", "111");
			System.out.println(jsonmsg);
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
		}
	}

	private void listPhonePlanMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String planUserId = request.getParameter("planUserId");
		List<Object> params = new ArrayList<Object>();
		params.add(planUserId);
		List<Map<String, Object>> flagFood = hobbyDao.listPhonePlanMessage(params);
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", flagFood);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void listSceneryPhoneMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		List<Map<String, Object>> flagFood = hobbyDao.listscenerymsgTypeMessage();
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", flagFood);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void listSceneryMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		List<Map<String, Object>> list = hobbyDao.listscenerymsgTypeMessage();
		request.setAttribute("listMessage", list);
		request.getRequestDispatcher("../sceneryMessage.jsp").forward(request, response);

	}

	private void addScenery(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		final long MAX_SIZE = 2048 * 1024 * 1024;// 设置上传文件最大值为2G，可以改为更大
		// 表单含有文件要提交
		String path = request.getContextPath();
		DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
		// 构建一个文件上传类
		ServletFileUpload servletFileUpload = new ServletFileUpload(diskFileItemFactory);
		// servletFileUpload.setFileSizeMax(3 * 1024 * 1024);
		servletFileUpload.setSizeMax(MAX_SIZE);// 上传文件总大小
		List<FileItem> list = null;
		List<Object> params = new ArrayList<Object>();
		try {
			// 解析request的请求
			list = servletFileUpload.parseRequest(request);
			// 取出所有表单的值:判断非文本字段和文本字段
			for (FileItem fileItem : list) {
				if (fileItem.isFormField()) {
					if (fileItem.getFieldName().equals("sceneryTitle")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));
					}

					if (fileItem.getFieldName().equals("sceneryMoney")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));
					}

					if (fileItem.getFieldName().equals("sceneryAddress")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));
					}

					if (fileItem.getFieldName().equals("sceneryMessage")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));
					}

					if (fileItem.getFieldName().equals("sceneryTraffic")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));
					}

					if (fileItem.getFieldName().equals("sceneryHotel")) {
						params.add(fileItem.getString("utf-8"));
						System.out.println(fileItem.getString("utf-8"));

						SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");// 设置日期格式
						params.add(df.format(new Date()));
						System.out.println(df.format(new Date()));
					}

				} else {
					try {
						// String image = fileItem.getName();
						// System.out.println("image--->>" + image);
						// params.add(image);E:\2017-2018code\A1044VideoCourse\VideoCourseService
						// String upload_path = request.getRealPath("/upload");
						// System.out.println("--->>" + upload_path);
						// File real_path = new File(upload_path + "/" + image);
						// fileItem.write(real_path);
						String image = fileItem.getName();
						System.out.println("image111--->>" + image);
						params.add(image);
						String upload_path = request.getRealPath("/upload");
						System.out.println("--->>" + upload_path);
						String imgPath = "E:\\2017-2017CDCode\\Tourism\\TourismService\\WebRoot\\upload";
						imgPath = request.getServletContext().getRealPath("/") + "\\upload";
						File real_path = new File(imgPath + "/" + image);
						fileItem.write(real_path);

						// 把数据插入到数据库中
					} catch (Exception e) {
						e.printStackTrace();
					}

					boolean flag = hobbyDao.addSceneryMessage(params);
					System.out.println(flag);
					if (flag) {
						listSceneryMessage(request, response);
					} else {
						System.out.println("flag:no");
					}

				}
			}
		} catch (FileUploadException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	private void deleteType(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String typeId = request.getParameter("typeId");
		List<Object> params = new ArrayList<Object>();
		params.add(typeId);
		boolean flag = hobbyDao.deleteType(params);
		if (flag) {
			listTypeMessage(request, response);
		}

	}

	private void deleteScenery(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String sceneryId = request.getParameter("sceneryId");
		List<Object> params = new ArrayList<Object>();
		params.add(sceneryId);
		boolean flag = hobbyDao.deletescenerymsgType(params);
		if (flag) {
			listSceneryMessage(request, response);
		}

	}

	private void addType(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();

		String typeName = request.getParameter("typeName");
		List<Object> params = new ArrayList<Object>();
		params.add(typeName);
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");// 设置日期格式
		params.add(df.format(new Date()));
		boolean flag = hobbyDao.addType(params);

		if (flag) {
			listTypeMessage(request, response);

		} else {
			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "提交失败");
			jsonmsg.put("repCode", "111");
			System.out.println(jsonmsg);
			// response.getWriter().print(jsonmsg);// 将路径返回给客户端
		}

	}

	private void listTypeMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		List<Map<String, Object>> list = hobbyDao.listTypeMessage();
		request.setAttribute("listMessage", list);
		request.getRequestDispatcher("../typeMessage.jsp").forward(request, response);

	}

	private void deleteCollectMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		String collectUserId = request.getParameter("collectUserId");
		String collectMessageId = request.getParameter("collectMessageId");
		List<Object> params = new ArrayList<Object>();
		params.add(collectUserId);
		params.add(collectMessageId);
		boolean flag = hobbyDao.deleteCollect(params);
		if (flag) {
			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "取消成功");
			jsonmsg.put("repCode", "666");
			System.out.println(jsonmsg);
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
		} else {
			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "取消失败");
			jsonmsg.put("repCode", "111");
			System.out.println(jsonmsg);
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
		}

	}

	private void addCollectMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		String collectUserId = request.getParameter("collectUserId");
		String collectUserName = request.getParameter("collectUserName");
		String collectMessageId = request.getParameter("collectMessageId");
		List<Object> params = new ArrayList<Object>();
		params.add(collectUserId);
		params.add(collectUserName);
		params.add(collectMessageId);
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");// 设置日期格式
		params.add(df.format(new Date()));
		boolean flag = hobbyDao.addMusicMessage(params);
		if (flag) {
			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "收藏成功");
			jsonmsg.put("repCode", "666");
			System.out.println(jsonmsg);
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
		} else {
			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "收藏失败");
			jsonmsg.put("repCode", "111");
			System.out.println(jsonmsg);
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
		}

	}

	private void deletePcInterest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String interestId = request.getParameter("interestId");
		List<Object> params = new ArrayList<Object>();
		params.add(interestId);
		boolean flag = hobbyDao.deleteInter(params);
		if (flag) {
			listMessage(request, response);
		}

	}

	private void deleteInterest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		String interestId = request.getParameter("interestId");
		List<Object> params = new ArrayList<Object>();
		params.add(interestId);
		boolean flag = hobbyDao.deleteInter(params);
		if (flag) {
			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "删除成功");
			jsonmsg.put("repCode", "666");
			System.out.println(jsonmsg);
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
		} else {
			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "提交失败");
			jsonmsg.put("repCode", "111");
			System.out.println(jsonmsg);
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
		}
	}

	private void listInterestUserMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String interestUserId = request.getParameter("interestUserId");
		List<Object> params = new ArrayList<Object>();
		params.add(interestUserId);

		List<Map<String, Object>> flagFood = hobbyDao.listInterestUserMessage(params);
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", flagFood);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void listInterestMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String userId = request.getParameter("userId");
		List<Map<String, Object>> flagFood = hobbyDao.listInterestMessage(userId);
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", flagFood);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void addInterest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String interestTitle = request.getParameter("interestTitle");
		String interestType = request.getParameter("interestType");
		String interestAddress = request.getParameter("interestAddress");
		String interestLatLon = request.getParameter("interestLatLon");
		String interestTypeId = request.getParameter("interestTypeId");
		String interestMessage = request.getParameter("interestMessage");
		String interestUserId = request.getParameter("interestUserId");
		String interestUserName = request.getParameter("interestUserName");
		String interestImage = request.getParameter("interestImage");
		String imagePath = null;
		if (interestTitle == null) {
			try {
				List<FileItem> items = this.upload.parseRequest(request);
				if (items != null && !items.isEmpty()) {
					for (FileItem fileItem : items) {
						String filename = fileItem.getName();
						// E:\2017-2018code\A432University\UniversityLifeService
						String imgPath = "E:\\2017-2018code\\A1328Community\\CommunityService\\WebRoot\\upload";

						System.out.println("文件保存路径为:" + imgPath + "/" + filename);

						File real_path = new File(imgPath + "/" + filename);
						// File file = new File(filepath);
						InputStream inputSteam = fileItem.getInputStream();
						BufferedInputStream fis = new BufferedInputStream(inputSteam);
						FileOutputStream fos = new FileOutputStream(real_path);
						int f;
						while ((f = fis.read()) != -1) {
							fos.write(f);
						}
						fos.flush();
						fos.close();
						fis.close();
						inputSteam.close();
						System.out.println("文件：" + filename + "上传成功!");
						imagePath = filename;

					}
				}

			} catch (FileUploadException e) {
				e.printStackTrace();
			}
		} else {
			List<Object> params = new ArrayList<Object>();
			params.add(interestTitle + "");
			params.add(interestType + "");
			params.add(interestTypeId + "");
			params.add(interestAddress + "");
			params.add(interestLatLon + "");

			params.add(interestMessage + "");
			params.add(interestUserId + "");
			params.add(interestUserName + "");
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");// 设置日期格式
			params.add(df.format(new Date()));
			params.add(interestImage + "");

			boolean flag = hobbyDao.addInterest(params);
			System.out.println(flag + "");
			if (flag) {
				System.out.println("上传文件成功!");
				JSONObject jsonmsg = new JSONObject();
				jsonmsg.put("repMsg", "处理成功");
				jsonmsg.put("repCode", "666");
				response.getWriter().print(jsonmsg);// 将路径返回给客户端

			} else {
				System.out.println("上传文件失败");
			}
		}
	}

	private void queryMRMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String medicalRecordPatientId = request.getParameter("medicalRecordPatientId");
		String appointmentId = request.getParameter("appointmentId");
		List<Object> params = new ArrayList<Object>();
		params.add(medicalRecordPatientId);
		params.add(appointmentId);
		Map<String, Object> flagFood = hobbyDao.queryMRMessage(params);
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", flagFood);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void addMRMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		String medicalRecordPatientId = request.getParameter("medicalRecordPatientId");
		String medicalRecordPatientName = request.getParameter("medicalRecordPatientName");
		String medicalRecordPatientPhone = request.getParameter("medicalRecordPatientPhone");
		String medicalRecordPatientTime = request.getParameter("medicalRecordPatientTime");
		String medicalRecordPatientMessage = request.getParameter("medicalRecordPatientMessage");
		String medicalRecordDoctorId = request.getParameter("medicalRecordDoctorId");
		String medicalRecordDoctorName = request.getParameter("medicalRecordDoctorName");
		String appointmentId = request.getParameter("appointmentId");

		List<Object> params = new ArrayList<Object>();
		params.add(medicalRecordPatientId);
		params.add(medicalRecordPatientName);
		params.add(medicalRecordPatientPhone);
		params.add(medicalRecordPatientTime);
		params.add(medicalRecordPatientMessage);
		params.add(medicalRecordDoctorId);
		params.add(medicalRecordDoctorName);
		params.add(appointmentId);

		boolean flag = hobbyDao.addMRMessage(params);
		JSONObject jsonmsg = new JSONObject();
		if (flag) {
			jsonmsg.put("repMsg", "提交成功");
			jsonmsg.put("repCode", "666");
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
			System.out.println(jsonmsg);
		} else {
			jsonmsg.put("repMsg", "提交失败");
			jsonmsg.put("repCode", "111");
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
			System.out.println(jsonmsg);
		}
	}

	private void listDoctorQueryAppointmentMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String appointmentDoctorId = request.getParameter("appointmentDoctorId");
		List<Object> params = new ArrayList<Object>();
		params.add(appointmentDoctorId);
		List<Map<String, Object>> flagFood = hobbyDao.listDoctorAppointmentmsgMessage(params);
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", flagFood);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void listAppointmentMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String appointmentUserId = request.getParameter("appointmentUserId");
		List<Object> params = new ArrayList<Object>();
		params.add(appointmentUserId);
		List<Map<String, Object>> flagFood = hobbyDao.listAppointmentmsgMessage(params);
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", flagFood);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void addAppointment(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();

		String appointmentDoctorId = request.getParameter("appointmentDoctorId");
		String appointmentDoctorName = request.getParameter("appointmentDoctorName");
		String appointmentUserId = request.getParameter("appointmentUserId");
		String appointmentUserName = request.getParameter("appointmentUserName");

		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");// 设置日期格式

		List<Object> paramsCheck = new ArrayList<Object>();
		paramsCheck.add(appointmentDoctorId);
		paramsCheck.add(df.format(new Date()));
		int appNumber = hobbyDao.getItemCount(paramsCheck);

		List<Object> params = new ArrayList<Object>();
		params.add(appointmentDoctorId);
		params.add(appointmentDoctorName);
		params.add(appointmentUserId);
		params.add(appointmentUserName);
		params.add(df.format(new Date()));

		if (appNumber == 0) {
			params.add("1");
		} else {
			params.add(appNumber + 1);
		}

		boolean flag = hobbyDao.addAppointment(params);
		JSONObject jsonmsg = new JSONObject();
		if (flag) {
			jsonmsg.put("repMsg", "预约成功");
			jsonmsg.put("repCode", "666");
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
			System.out.println(jsonmsg);
		} else {
			jsonmsg.put("repMsg", "预约失败");
			jsonmsg.put("repCode", "111");
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
			System.out.println(jsonmsg);
		}
	}

	private void addMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();

		String planName = request.getParameter("planName");
		String planTime = request.getParameter("planTime");
		String planUserId = request.getParameter("planUserId");
		String planUserName = request.getParameter("planUserName");

		List<Object> params = new ArrayList<Object>();
		params.add(planName);
		params.add(planTime);
		params.add(planUserId);
		params.add(planUserName);

		System.out.println(planName);
		System.out.println(planTime);
		System.out.println(planUserId);
		System.out.println(planUserName);

		boolean flag = hobbyDao.addMessage(params);
		JSONObject jsonmsg = new JSONObject();
		if (flag) {
			jsonmsg.put("repMsg", "提交成功");
			jsonmsg.put("repCode", "666");
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
			System.out.println(jsonmsg);
		} else {
			jsonmsg.put("repMsg", "提交失败");
			jsonmsg.put("repCode", "111");
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
			System.out.println(jsonmsg);
		}
	}

	private void listSearchMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		String searchMsg = request.getParameter("searchMsg");
		List<Map<String, Object>> list = hobbyDao.listSearchMessage(searchMsg);
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", list);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void deleteMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String flowerId = request.getParameter("flowerId");
		List<Object> params = new ArrayList<Object>();
		params.add(flowerId);
		boolean flag = hobbyDao.deleteMessage(params);
		if (flag) {
			listMessage(request, response);
		}

	}

	private void updateReview(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String rId = request.getParameter("rId");
		String replyContent = request.getParameter("replyContent");
		List<Object> params = new ArrayList<Object>();
		params.add(replyContent);
		params.add(rId);
		boolean flag = hobbyDao.updateMessage(params);
		if (flag) {
			List<Map<String, Object>> list = hobbyDao.listReviewMessage();
			request.setAttribute("listMessage", list);
			request.getRequestDispatcher("../reviewListMessage.jsp").forward(request, response);
		}

	}

	private void listPhoneMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		List<Map<String, Object>> flagFood = hobbyDao.listPhoneMessage();
		JSONObject jsonmsg = new JSONObject();
		jsonmsg.put("repMsg", "请求成功");
		jsonmsg.put("repCode", "666");
		jsonmsg.put("data", flagFood);
		System.out.println(jsonmsg);
		response.getWriter().print(jsonmsg);// 将路径返回给客户端

	}

	private void listMessageChoice(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		List<Map<String, Object>> list = hobbyDao.listMessage();
		request.setAttribute("listMessage", list);
		request.getRequestDispatcher("../formJob.jsp").forward(request, response);

	}

	private void listMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();
		List<Map<String, Object>> list = hobbyDao.listMessage();
		request.setAttribute("listMessage", list);
		request.getRequestDispatcher("../interMessage.jsp").forward(request, response);

	}

	private void addOldMessage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String path = request.getContextPath();

		String naviName = request.getParameter("naviName");
		String naviJD = request.getParameter("naviJD");
		String naviWD = request.getParameter("naviWD");
		List<Object> params = new ArrayList<Object>();
		params.add(naviName);
		params.add(naviJD);
		params.add(naviWD);
		boolean flag = hobbyDao.addMessage(params);
		if (flag) {
			listMessage(request, response);
		} else {
			JSONObject jsonmsg = new JSONObject();
			jsonmsg.put("repMsg", "提交失败");
			jsonmsg.put("repCode", "111");
			System.out.println(jsonmsg);
			response.getWriter().print(jsonmsg);// 将路径返回给客户端
		}

	}

}
